import {
  createInbizSchema,
  createBaseSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
  createModelSchema,
  createValidatorSchema,
  createComponentLayout,
  createControllerSchema,
} from '@inbiz/setters';

export const commonProps = {
  title: {
    status: true,
    value: 'EformMemberSelect.title',
  },
};

export const defaultProps = {
  label: {
    status: true,
    value: 'EformMemberSelect.title',
  },
  placeholder: 'EformMemberSelect.lang.plzSelect',
  multiple: false,
  tabs: ['user', 'group', 'position', 'department'],
  readonly: false,
  visible: false,
  className: '',
};

// Shema
export const propsSchema = createInbizSchema({
  attribute: {
    ...createBaseSchema({
      placeholder: {
        type: 'string',
        'x-decorator': 'FormItem',
        'x-component': 'MultilingualInput',
      },
      selectedType: {
        type: 'string',
        enum: ['name', 'nameUsername'],
        'x-decorator': 'FormItem',
        'x-component': 'Select',
        'x-component-props': {
          defaultValue: 'name',
        },
      },
      tabs: {
        type: 'string',
        'x-decorator': 'FormItem',
        'x-component': 'Checkbox.Group',
        enum: ['department', 'position', 'group', 'user'],
      },
      multiple: {
        type: 'boolean',
        'x-decorator': 'FormItem',
        'x-component': 'Switch',
      },
    }),
    ...createValidatorSchema(false, {}),
  },
  style: {
    ...createComponentStyleSchema(),
    ...createComponentLayout(),
    ...createDecoratorStyleSchema(),
  },
  senior: {
    ...createModelSchema({
      childModelConfig: {
        type: 'boolean',
        'x-decorator': 'FormItem',
        'x-component': 'Switch',
      },
      storageConfig: {
        type: 'object',
        'x-decorator': 'FormItem',
        'x-component': 'StorageConfig',
        'x-component-props': {
          type: 'member',
        },
        'x-reactions': {
          dependencies: ['.childModelConfig'],
          fulfill: {
            state: {
              visible: "{{$deps == 'true'}}",
            },
          },
        },
      },
    }),
  },
  controller: createControllerSchema({
    events: [
    {
      name: "onOpen",
      label: "弹框打开事件"
    },
    {
      name: "onChange",
      label: "点击确定按钮事件"
    },
    {
      name: "onBeforeOpen",
      label: "弹框打开前事件"
    },
    {
      name: "onBeforeChange",
      label: "组件值改变前事件"
    },
    {
      name: "onChange",
      label: "组件值改变前回调事件"
    }]
  })
});
